//
//  StatusCell.swift
//  开心微博
//
//  Created by 郑开心 on 15/12/13.
//  Copyright © 2015年 郑开心. All rights reserved.
//

import UIKit

class StatusCell: UITableViewCell {
    
    var originalView : OriginalView!
    var retweetView : RetweetView!
    var statusToolBar : StatusToolBar!
    
    var statusFrame : StatusFrame!{
        didSet{
            setStatus()
        }
    }

    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style,reuseIdentifier: reuseIdentifier)
        //self.userInteractionEnabled = false
        setUpAllChindView()
        self.backgroundColor = UIColor.clearColor()
    
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    /**
     添加全部子view
     */
    func setUpAllChindView(){
        //原创微博
        originalView = OriginalView(frame: CGRectMake(0, 0, 0, 0))
        self.addSubview(originalView)

        //转发微博
        retweetView = RetweetView(frame: CGRectMake(0, 0, 0, 0))
        self.addSubview(retweetView)
        
        //工具条
        statusToolBar = StatusToolBar(frame: CGRectMake(0, 0, 0, 0))
        self.addSubview(statusToolBar)
    }
    
    func setStatus(){
        
        originalView.frame = statusFrame.originalFrame
        originalView.statusFrame = statusFrame
        
        
        retweetView.frame = statusFrame.retweetViewFrame
        retweetView.statusFrame = statusFrame
        
        statusToolBar.frame = statusFrame.statusToolFrame
        statusToolBar.statusFrame = statusFrame
    }
    
    class func cellWithTableView(tableView: UITableView) -> StatusCell{
        let ID = "cell"
        var cell = tableView.dequeueReusableCellWithIdentifier(ID) as? StatusCell
        if cell == nil {
            cell = StatusCell(style: UITableViewCellStyle.Subtitle, reuseIdentifier: ID)
        }
        
        return cell!
    }
}
